/*****************************************************************
ELDATool
Copyright (C) 2012 G. Fortino

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation;
version 2.1 of the License.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*****************************************************************/

//Generated by StarUML(tm) Java Add-In

//@ Project : Untitled
//@ File Name : SimMao.java
//@ Date : 24/12/2007
//@ Author : 

package eldasim.agent;

import java.io.Serializable;

import eldaframework.agent.ELDABehavior;
import eldaframework.agent.ELDAId;
import eldaframework.dsc.AState;
import eldaframework.dsc.ELDAActiveState;
import eldaframework.eldaevent.ELDAEvent;
import eldasim.AgentServer;

public class SimELDA implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private ELDABehavior ebeh;
	protected SimELDA requester;
	transient private ELDAId eid;
	transient private AgentServer as;

	public SimELDA(ELDAId eid, ELDAActiveState activeState, AgentServer as) {
		this.eid = eid;
		this.as = as;
		ebeh = new ELDABehavior(activeState);
		ebeh.setMID(eid);
		ebeh.setTLH(as.getTlh());
	}

	public void setELDAId(ELDAId id) {
		this.eid = id;
	}

	public ELDAId getELDAId() {
		return eid;
	}

	public void receive(ELDAEvent evt) {
		ebeh.dispatch(evt);
	}

	public ELDABehavior getEbeh() {
		return ebeh;
	}

	public void setEbeh(ELDABehavior ebeh) {
		this.ebeh = ebeh;
	}

	public AgentServer getAs() {
		return as;
	}

	public void setAs(AgentServer as) {
		eid.setCurrLocation(as.getName());
		ebeh.setTLH(as.getTlh());
	}

	public AState getActiveState() {
		return ebeh.getCurrentState();
	}

}
